/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.EditPanes.Other;

import GUI.EditPanes.EditTaskPane;
import General.CurrentData;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Spatial;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JComboBox;

/**
 *
 * @author David
 */
public class ShadowModeTaskPane extends EditTaskPane
{

    private JComboBox<String> modeComboBox = new JComboBox<String>(new String[]
    {
        "Cast", "Recieve", "Cast & Recieve", "Inherit", "Off"
    });
    private Spatial spatial;

    /**
     *
     */
    public ShadowModeTaskPane()
    {
        spatial = (Spatial) CurrentData.getEditorWindow().getB3DApplication().getSelectedObject();
        if (spatial.getShadowMode().equals(RenderQueue.ShadowMode.Cast))
        {
            modeComboBox.setSelectedIndex(0);
        } else if (spatial.getShadowMode().equals(RenderQueue.ShadowMode.Receive))
        {
            modeComboBox.setSelectedIndex(1);
        } else if (spatial.getShadowMode().equals(RenderQueue.ShadowMode.CastAndReceive))
        {
            modeComboBox.setSelectedIndex(2);
        } else if (spatial.getShadowMode().equals(RenderQueue.ShadowMode.Inherit))
        {
            modeComboBox.setSelectedIndex(3);
        } else
        {
            modeComboBox.setSelectedIndex(4);
        }
        modeComboBox.addItemListener(new ItemListener()
        {
            public void itemStateChanged(ItemEvent e)
            {
                switch (modeComboBox.getSelectedIndex())
                {
                    case 0:
                        spatial.setShadowMode(RenderQueue.ShadowMode.Cast);
                        break;
                    case 1:
                        spatial.setShadowMode(RenderQueue.ShadowMode.Receive);
                        break;
                    case 2:
                        spatial.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
                        break;
                    case 3:
                        spatial.setShadowMode(RenderQueue.ShadowMode.Inherit);
                        break;
                    case 4:
                        spatial.setShadowMode(RenderQueue.ShadowMode.Off);
                        break;
                }
            }
        });
        taskPane.setTitle("Shadow Mode");
        taskPane.add(modeComboBox, BorderLayout.CENTER);
        add(taskPane, BorderLayout.CENTER);
    }
}
